<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>工厂函数</title>
	</head>
	<body>
		<script>
		function createObject(name,sex,jia){
			var a = new Object();
			a.name = name;
			a.sex = sex;
			a.jia = jia;
			a.r = function (){
				alert("车名："+this.name+"   日期:"+this.sex+"    价格:"+this.jia);
			};
			//返回对象
			return a;
		}
		//对象调用方法
		var cheliang = createObject("奔驰","2017/01/01","一百万");
		    cheliang.r();
		</script>
	</body>
</html>
